package com.wangzh.nio.chars;


import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class FileReaderDemo {
    public static void main(String[] args) throws IOException {
        test2();
    }

    private static void test2() throws IOException {
        FileReader fr = new FileReader("filea.txt");
        int ch;
        char[] chars = new char[2];
        while ((ch = fr.read(chars)) != -1){
            System.out.print(new String(chars,0,ch));
        }
        fr.close();
    }
    private static void test() throws IOException {
        FileReader fr = new FileReader("filea.txt");
        int ch;
        while ((ch = fr.read()) != -1){
            System.out.print((char) ch);
        }
        fr.close();
    }
}
